var albumStatus = 'new';
var maxNumImgs = $('#maxImgs');
var numShownImgForms = 0;

function upload(){
    if(albumStatus == 'new'){
        $.get(  
            $('#createAlbumURL'),
            {albumName: $('#albums_name')},  
            function(responseText){  
                
                if(responseText == 'done'){
                    //upload images
                    albumStatus = 'created';
                }
                else{
                    //alert
                }
            },  
            "html"  
        ); 
    }
    else if (albumStatus == 'changed'){
        $.get(  
            $('#renameAlbumURL'),
            {albumName: $('#albums_name')},  
            function(responseText){  
                
                if(responseText == 'done'){
                    //upload images
                }
                else{
                    //alert
                }
            },  
            "html"  
        ); 
    }
}

function uploadImages(){
    imgForms = $('.imgForm');
    $.each(imgForms, function(k,v){
       //status = $( v " .imgStatus:first" ); 
       status = $this.$('.status').value;
       if(status == 'new'){
           $.post(  
            $('#uploadFileURL'),
            $this.serialize(),  
            function(responseText){  
                
                if(responseText != 0){
                    //inset hidden field with imgId
                    //update uploaded images
                    //make field disabled
                }
                else{
                    //alert
                }
            },  
            "html"  
        );
       }
       else if(status = 'changed'){
           $.get(  
            $('#changeFileNameURL'),
            {imgName: $this.$('#imgName'), imgId: $this.$('#imgId')},  
            function(responseText){  
                
                if(responseText == 'done'){
                    //update uploaded images
                }
                else{
                    //alert
                }
            },  
            "html"  
        );
       }
    });
}






